package DBLayer;
import java.net.URL;
import java.sql.*;
import java.util.*;

public class DBConnection
{   
    private static final String  driver = "jdbc:sqlserver://balder.ucn.dk:1433";
    private static final String  databaseName = ";databaseName=dm75_1";

    private static String  userName = "; user=dm75_1";
    private static String password = ";password=MaaGodt";
   
  
    private DatabaseMetaData dma;
    private static Connection con;
  
    private static DBConnection  instance = null;

    private DBConnection()
    {
    	String url = driver + databaseName + userName + password;

        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        }
        catch(Exception e)
        {

        }
        try
        {
            con = DriverManager.getConnection(url);
            
            con.setAutoCommit(true);
            dma = con.getMetaData(); 
        }
        catch(Exception e)
        {

        }
    }
	   
    public static void closeConnection()
    {
        try
        {
            con.close();
        }
        catch (Exception e)
        {
            
        }
    }
		
    public  Connection getDBcon()
    {
       return con;
    }

    public static DBConnection getInstance()
    {
        if (instance == null)
        {
          instance = new DBConnection();
        }
        
        return instance;
    }

}